﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Danser_Entity.Entities;

namespace Danser_AJAXEnabledWebApplication
{
    /// <summary>
    /// Master template for all main system pages
    /// </summary>
    public partial class Danser : System.Web.UI.MasterPage
    {
        #region Members:

        private PermissionLevel _userPermission;
        private string _userID;

        #endregion

        #region Page Load:

        /// <summary>
        /// loads the page...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        #endregion

        #region Control Methods:

        /// <summary>
        /// Is called once from the welcome page
        /// </summary>
        public void exposeRelevantButtons(PermissionLevel userPermission)
        {
            switch (userPermission)
            {
                case PermissionLevel.Viewer:
                    authorizationButton.Visible = false;
                    dataValidationsButton.Visible = false;
                    editDataButton.Visible = false;
                    uploadDataButton.Visible = false;
                    break;

                case PermissionLevel.Editor:
                    authorizationButton.Visible = false;
                    dataValidationsButton.Visible = false;
                    editDataButton.Visible = false;
                    break;

                case PermissionLevel.Manager:
                    authorizationButton.Visible = false;
                    break;

                case PermissionLevel.Admin:
                    break;

                default: //none
                    Response.Redirect("~/Faults/UnAuthorizedAccess.aspx", true);
                    break;
            }
        }

        #endregion

        #region Properties:

        /// <summary>
        /// property
        /// </summary>
        public string UserID
        {
            get { return _userID; }
            set
            {
                _userID = value;
                userNameLabel.Text = value;
            }
        }

        /// <summary>
        /// property
        /// </summary>
        public PermissionLevel UserPermission
        {
            get { return _userPermission; }
            set { _userPermission = value; }
        }

        //getters for the buttons
        /// <summary>
        /// property
        /// </summary>
        public Button AuthorizationButton
        {
            get {return authorizationButton;}
        }

        /// <summary>
        /// property
        /// </summary>
        public Button DataValidationsButton
        {
            get {return dataValidationsButton;}
        }

        /// <summary>
        /// property
        /// </summary>
        public Button EditDataButton
        {
            get {return editDataButton;}
        }

        /// <summary>
        /// property
        /// </summary>
        public Button UploadDataButton
        {
            get {return uploadDataButton;}
        }

        /// <summary>
        /// property
        /// </summary>
        public Button QueriesButton
        {
            get { return queriesButton; }
        }

        #endregion
    }
}
